package dmp.topk;

import java.io.IOException;
import java.util.TreeMap;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class TopkMapper extends Mapper<LongWritable, Text,  Text,Text> {
	private Text resultkey=new Text();
	private Text resultValue=new Text();
	@Override
	protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
		String line=value.toString();
		String[] words=line.split("\t");
		String user=words[0].split("\\|")[0];
		String url=words[0].split("\\|")[1];
		String count=words[1];
		resultkey.set(user);
		resultValue.set(url+"\t"+count);
		
		context.write(resultkey, resultValue);
	}
	
}
